<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/3/11/011
 * Time: 8:58
 */

namespace app\project\controller;


use app\common\controller\Common;
use app\index\controller\Base;
use think\Db;
use think\Exception;
use think\Session;

class Config extends Base
{

    /**
     * 配置详情
     */
    public function index(){
        //权限查询
        $common = new Common();
        $powerList = $common->showpower();
        $this->assign("powerList",$powerList);

        $thisWechat = Session::get("thisWechat");
        $where['uniacid'] = $thisWechat['id'];
        $config = Db::name("project_config")->where($where)->find();
        $this->assign("config",$config);

        return $this->fetch("index");
    }

    /**
     * 详情
     */
    public function detail(){

    }

    /**
     * 更新项目配置
     */
    public function update(){
        try{
            $data = $_POST;
            $thisWechat = Session::get("thisWechat");
            $where['uniacid'] = $thisWechat['id'];
            $id = Db::name("project_config")->where($where)->value("id");
            if(empty($id)){
                $data['uniacid'] = $thisWechat['id'];
                Db::name("project_config")->insert($data);
            }else{
                $data['id'] = $id;
                Db::name("project_config")->update($data);
            }
            $black['0'] = 202;
            $black['msg'] = "更新成功";
        }catch (Exception $e){
            $black['code'] = 202;
            $black['msg'] = $e->getMessage();
        }
        return $black;
    }

    /**
     * 删除操作
     */
    public function del(){

    }

}